<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{
            margin:0;
            padding:0;
        }
        form{
            margin-left: 20px;
            width: 200px;
            height: 350px;
            border:1px solid #000;
        }
        ul{
            list-style-type: none;
            text-align: center;
            border-bottom: 1px solid #000;
        }
        li{
            cursor: pointer;
            display: inline-block;
            line-height: 50px;
        }
        .current{
            color:orange;
        }
        .content{
            position: relative;
        }
        .content>div{
            position: absolute;
            left: 0;
            top:0;
            width: 200px;
            height: 300px;
        }
        .two{
            display: none;
        }
    </style>
</head>
<body>
    <form>
        <ul>
            <li class="current">账号登录</li>
            <li>扫码登录</li>
        </ul>
        <div class="content">
            <div>123</div>
            <div class="two">456</div>
        </div>
    </form>
    <script>
        var lis = document.getElementsByTagName("li");
        var contents = document.querySelectorAll(".content>div")
        for(var i=0;i<lis.length;i++){
            lis[i].index = i;
            lis[i].onclick = function(){
                for(var m=0;m<lis.length;m++){
                    lis[m].className="";
                }
                this.className = "current";
                for(var k=0;k<contents.length;k++){
                    contents[k].style.display="none";

                }
                contents[this.index].style.display="block";
                console.log(this.index);
            }
        }
        
    </script>
</body>
</html>